﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using HitachiLib.HitachiServiceRef;
using HitachiApp.Model;

namespace HitachiLib.Utils
{
    public class WCFClient
    {
        public static HitachiServiceClient GetClient()
        {
            try
            {
                HitachiServiceClient client = new HitachiServiceClient("BasicHttpBinding_IHitachiService");
                return client;
            }
            catch (Exception e)
            {
                String s = e.Message;
            }
            return null;
        }

        private static MainPageModel model = null;
        public static void InitMainPage(MainPageModel m)
        {
            if (m is MainPageModel)
                model = m;
        }

        private static int in_use = 0;
        public static bool IsInUse()
        {
            return in_use > 0;
        }

        public static void Retain()
        {
            in_use++;
            model.LockChanged();
        }
        public static void Release()
        {
            in_use--;
            model.LockChanged();
        }
    }
}
